


public class Text1 {
    public static void main13(String[] args) {
        String str="hello";
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append(str);
        stringBuilder.append("world");
        str=stringBuilder.toString();
        System.out.println(str);
    }
    public static void main12(String[] args) {
        String str=new String("abc");
        String str1=new String("a")+new String("b");
    }
    public static void main11(String[] args) {
        int [] array=new int []{1,2,3};
        array=new int[]{4,5,6};
        array[0]=99;
    }
    public static void main10(String[] args) {
        String str = "helloworld" ;
        System.out.println(str.substring(5));
        System.out.println(str.substring(0, 5));
    }
    public static void main9(String[] args) {
//        String str = "hello world hello bit" ;
//        String[] result = str.split(" ") ; // 按照空格拆分
//        for(String s: result) {
//            System.out.println(s);
//        }
//        String str = "hello world hello world" ;
//        String[] result = str.split(" ",2) ;
//        for(String s: result) {
//            System.out.println(s);
//        }
        String str = "name=zhangsan&age=18" ;
        String[] result = str.split("&") ;
        for (int i = 0; i < result.length; i++) {
            String[] temp = result[i].split("=") ;
            System.out.println(temp[0]+" = "+temp[1]);
        }

    }
    public static void main8(String[] args) {
        String str = "helloworld" ;
        System.out.println(str.replaceAll("l", "_"));
        System.out.println(str.replaceFirst("l", "_"));
    }
    public static void main7(String[] args) {
        String s = "hello";
// 字符串转数组
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.print(ch[i]);
        }
        System.out.println();
// 数组转字符串
        String s2 = new String(ch);
        System.out.println(s2);
        String ss = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(ss);

    }
    public static void main6(String[] args) {
        String s1 = "Hello";
        String s2 = "HELLo";
// 小写转大写
        System.out.println(s1.toUpperCase());
// 大写转小写
        System.out.println(s2.toLowerCase());
    }
    public static void main5(String[] args) {
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        int data1 = Integer.parseInt("1234");
        double data2 = Double.parseDouble("12.34");
        System.out.println(data1);
        System.out.println(data2);



    }
    public static void main3(String[] args) {
        String arr="abcdefgabcdef";
        System.out.println(arr.lastIndexOf("de",6));
        System.out.println(arr.lastIndexOf('a'));
        System.out.println(arr.lastIndexOf('d', 12));
        System.out.println(arr.indexOf("ef", 8));
        System.out.println(arr.indexOf("ef"));

        System.out.println(arr.indexOf('d', 1));
        System.out.println(arr.indexOf('d', 4));
        System.out.println(arr.indexOf('f'));
        System.out.println(arr.indexOf('z'));
//        System.out.println(arr.charAt(2));
//        System.out.println(arr.charAt(10));

    }
    public static void main2(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("ac");
        String s3 = new String("ABc");
        String s4 = new String("abcdef");
        System.out.println(s1.compareToIgnoreCase(s2));
        System.out.println(s1.compareToIgnoreCase(s3));
        System.out.println(s1.compareToIgnoreCase(s4));
    }
    public static void main1(String[] args) {

            String s1 = new String("abc");
            String s2 = new String("ac");
            String s3 = new String("abc");
            String s4 = new String("abcdef");
            System.out.println(s1.compareTo(s2)); // 不同输出字符差值-1
            System.out.println(s1.compareTo(s3)); // 相同输出 0
            System.out.println(s1.compareTo(s4)); // 前k个字符完全相同，输出长度差值 -3


    }

}

